package com.aaron.smyth.bossmoney;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;

public class DashboardLayout extends ViewGroup
{
	private static final int UNEVEN_GRID_PENALTY_MULTIPLIER = 10;
	
	private int mMaxChildWidth = 0;
	private int mMaxChildHeight = 0;
	
	public DashboardLayout(Context _context)
	{
		super(_context, null);
	}
	
	public DashboardLayout(Context _context, AttributeSet _attrs)
	{
		super(_context, _attrs, 0);
	}
	
	public DashboardLayout(Context _context, AttributeSet _attrs, int _defStyle)
	{
		super(_context, _attrs, _defStyle);
	}
	
	@Override
	protected void onMeasure(int _widthMeasureSpec, int _heightMeasureSpec)
	{
		mMaxChildWidth = 0;
		mMaxChildHeight = 0;
		
		// measure once to find the maximum child size
		int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(_widthMeasureSpec, MeasureSpec.AT_MOST);
		int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(_heightMeasureSpec), MeasureSpec.AT_MOST);
		
		final int count = getChildCount();
		for(int index = 0; index < count; index++)
		{
			final View child = getChildAt(index);
			if(child.getVisibility() == GONE)
			{
				continue;
			}
			
			child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
			
			mMaxChildWidth = Math.max(mMaxChildWidth, child.getMeasuredWidth());
			mMaxChildHeight = Math.max(mMaxChildHeight, child.getMeasuredHeight());
		}
		
		// measure again for each child to be exactly the same size.
		
	}

	@Override
	protected void onLayout(boolean arg0, int arg1, int arg2, int arg3, int arg4) {
		// TODO Auto-generated method stub
		
	}
}